// components/team/team.js
import Dialog from '@vant/weapp/dialog/dialog';
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    visible: false,
    data: {}
  },

  ready() {
    app.$request.teamDashboard()
    .then(res => {
      if (res.code === 1 && res.data) {
        this.setData({
          data: res.data,
          visible: true
        });
      }else{
        this.setData({
          visible: false
        });
        Dialog.alert({
          context: this,
          title: '提示',
          message: res.message
        })
      }
    })
  },

  /**
   * 组件的方法列表
   */
  methods: {
    serveOnline() {
      Dialog.alert({
        context: this,
        title: '提示',
        message: '请联系平台客服了解详细规则'
      })
    },
    rule() {
      wx.navigateTo({
        url: '../rule/rule',
      })
    },
    teamList(event) {
      let type = event.currentTarget.dataset.type;
      if(type === 'examine') {
        wx.navigateTo({
          url: `../teamLIstExamine/teamLIstExamine?type=${type}`,
        })
      }else{
        wx.navigateTo({
          url: `../teamList/teamList?type=${type}`,
        })
      }
    },
    onShareAppMessage() {
      const accountId = app.globalData.accountId;
      return {
        title: '',
        desc: '',
        path: `pages/index/index?shareId=${accountId}&type=team`,
        imageUrl: '', // 可以更换分享的图片
        success: function (res) {
          // 转发成功
          wx.showToast({
            title: '分享成功',
            icon: "none"
          });
        },
        fail: function (res) {
          // 转发失败
          wx.showToast({
            title: '分享失败',
            icon: "none"
          })
        }
      }
    },
    teamShare() {
      wx.navigateTo({
        url: '../teamShare/teamShare',
      })
    }
  }
})
